import { getAccessTypeEnumSchema } from '@/enums/accessTypeEnum';
import { AdColumn } from '@/components/AdTable';
import { useI18n } from '@/hooks/web/useI18n';

const { t } = useI18n();
const accessTypeEnumSchema = getAccessTypeEnumSchema();

export const columns: AdColumn[] = [
  {
    title: t('entity.idTitle'),
    dataIndex: 'Id',
    width: 180,
    ifShow: false,
    defaultHidden: true,
    formVisible: true,
    formEditable: false,
    filterable: false,
    dataType: 'integer',
  },
  {
    title: t('routes.system.authorization.function.nameTitle'),
    dataIndex: 'Name',
    fixed: 'left',
    width: 300,
    formVisible: true,
    formEditable: false,
    required: true,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('routes.system.authorization.function.accessTypeTitle'),
    dataIndex: 'AccessType',
    width: 100,
    formVisible: true,
    formEditable: true,
    required: true,
    filterable: true,
    dataType: 'enum',
    enumData: accessTypeEnumSchema,
  },
  {
    title: t('routes.system.authorization.function.isAccessTypeChangedTitle'),
    helpMessage: t('routes.system.authorization.function.isAccessTypeChangedPlaceholder'),
    dataIndex: 'IsAccessTypeChanged',
    width: 150,
    formVisible: false,
    formEditable: false,
    filterable: true,
    dataType: 'boolean',
  },
  {
    title: t('routes.system.authorization.function.auditOperationEnabledTitle'),
    dataIndex: 'AuditOperationEnabled',
    width: 150,
    formVisible: true,
    formEditable: true,
    filterable: true,
    dataType: 'boolean',
  },
  {
    title: t('routes.system.authorization.function.auditEntityEnabledTitle'),
    dataIndex: 'AuditEntityEnabled',
    width: 150,
    formVisible: true,
    formEditable: true,
    filterable: true,
    dataType: 'boolean',
    formCustomer: {
      colProps: {
        // span: 12,
        xs: 24, // <576px
        sm: 24, // ≥576px
        md: 12, // ≥768px
        lg: 12, // ≥992px
        xl: 12, // ≥1200px
        xxl: 6, // ≥1600px
        // xxxl: 6, // ≥2000px 3.0
      },
    },
  },
  {
    title: t('routes.system.authorization.function.cacheExpirationSecondsTitle'),
    helpMessage: t('routes.system.authorization.function.cacheExpirationSecondsPlaceholder'),
    dataIndex: 'CacheExpirationSeconds',
    width: 150,
    formVisible: true,
    formEditable: true,
    filterable: true,
    dataType: 'integer',
  },
  {
    title: t('routes.system.authorization.function.isCacheSlidingTitle'),
    helpMessage: t('routes.system.authorization.function.isCacheSlidingPlaceholder'),
    dataIndex: 'IsCacheSliding',
    width: 100,
    formVisible: true,
    formEditable: true,
    filterable: true,
    dataType: 'boolean',
  },
  {
    title: t('routes.system.authorization.function.isSlaveDatabaseTitle'),
    helpMessage: t('routes.system.authorization.function.isSlaveDatabasePlaceholder'),
    dataIndex: 'IsSlaveDatabase',
    width: 100,
    formVisible: true,
    formEditable: true,
    filterable: true,
    dataType: 'boolean',
  },
  {
    title: t('entity.lockable.isLockedTitle'),
    dataIndex: 'IsLocked',
    width: 70,
    formVisible: true,
    formEditable: true,
    filterable: true,
    dataType: 'boolean',
    formCustomer: {
      colProps: {
        // span: 12,
        xs: 24, // <576px
        sm: 24, // ≥576px
        md: 12, // ≥768px
        lg: 12, // ≥992px
        xl: 8, // ≥1200px
        xxl: 12, // ≥1600px
        // xxxl: 6, // ≥2000px 3.0
      },
    },
  },
  {
    title: t('routes.system.authorization.function.isAjaxTitle'),
    dataIndex: 'IsAjax',
    width: 100,
    formVisible: false,
    formEditable: false,
    filterable: true,
    dataType: 'boolean',
  },
  {
    title: t('routes.system.authorization.function.isControllerTitle'),
    dataIndex: 'IsController',
    width: 100,
    formVisible: false,
    formEditable: false,
    filterable: true,
    dataType: 'boolean',
  },
  {
    title: t('routes.system.authorization.function.areaTitle'),
    dataIndex: 'Area',
    width: 150,
    formVisible: false,
    formEditable: false,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('routes.system.authorization.function.controllerTitle'),
    dataIndex: 'Controller',
    width: 200,
    formVisible: false,
    formEditable: false,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('routes.system.authorization.function.actionTitle'),
    dataIndex: 'Action',
    width: 250,
    formVisible: false,
    formEditable: false,
    filterable: true,
    dataType: 'string',
  },
  {
    title: t('entity.creationAudited.createdTimeTitle'),
    dataIndex: 'CreatedTime',
    width: 180,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'datetime',
  },
  {
    title: t('entity.updateAudited.updatedTimeTitle'),
    dataIndex: 'UpdatedTime',
    width: 180,
    formVisible: true,
    formEditable: false,
    filterable: true,
    dataType: 'datetime',
  },
  {
    title: t('entity.dataVersion.dataVersionTitle'),
    dataIndex: 'DataVersion',
    width: 200,
    formVisible: true,
    formEditable: false,
    filterable: false,
    dataType: 'integer',
  },
];
